package cn.tedu.spring.scope;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//@Scope(value = "singleton") // 单实例
@Scope(value = "singleton")
@Component
public class Student {
    private String name;

    /**
     * 第1步
     */
    public Student() {
        System.out.println("01:bean对象创建,构造方法");
    }

    /**
     * 第2步
     * @param name
     */
    @Value("赵丽颖")
    public void setName(String name) {
        this.name = name;
        System.out.println("02:属性赋值,setter()方法");
    }

    /**
     * 第3步
     */
    @PostConstruct
    public void init(){
        System.out.println("03:执行初始化方法");
    }

    /**
     * 第5步
     */
    @PreDestroy
    public void destroy(){
        System.out.println("05:执行销毁方法");
    }
}









